--- layout: documentation title: Malloy Documentation footer: /generated/footers/visualizations/shape_maps.html ---

Shape Maps

The plugin currently supports US maps and state names. The model and data styles for the subsequent examples are:

explore: airports is table('malloy-data.faa.airports'){
  primary_key: code
  measure: airport_count is count(*)
  query: by_state is {
    where: state != null
    group_by: state
    aggregate: airport_count
  }
}

Data Styles

{
  "by_state": {
    "renderer": "shape_map"
  }
}

Run as a simple query

query: airports->{nest: by_state}
by_​state
5001,0001,500airport_count

Run as a trellis

By calling the configured map as a nested subtable, a trellis is formed.

query: airports->{
  group_by: faa_region
  aggregate: airport_count
  nest: by_state
}
faa_​region airport_​count by_​state
AGL 4,437 200400600800airport_count
ASW 3,268 5001,0001,500airport_count
ASO 2,924 200400600800airport_count
AEA 2,586 200400600800airport_count
ANM 2,102 200300400airport_count

Run as a trellis, repeated with different filters

query: airports->{
  group_by: faa_region
  aggregate: airport_count
  nest: [
    heliports is by_state {where: fac_type = 'HELIPORT'}
    seaplane_bases is by_state {where: fac_type = 'SEAPLANE BASE'}
  ]
}
faa_​region airport_​count heliports seaplane_​bases
AGL 4,437 50100150200airport_count 204060airport_count
ASW 3,268 100200300400airport_count 51015airport_count
ASO 2,924 50100150200250airport_count 10203040airport_count
AEA 2,586 100200300airport_count 5101520airport_count
ANM 2,102 50100150airport_count 51015airport_count